package com.example.zsr.downloadcontinue;

import android.os.Bundle;
import android.os.Environment;
import android.support.v7.app.AppCompatActivity;
import android.widget.ListView;
import android.widget.SeekBar;

import com.example.zsr.downloadcontinue.download.DownloadTaskManger;
import com.example.zsr.downloadcontinue.entity.DownloadConfigGuration;
import com.example.zsr.downloadcontinue.entity.FileInfo;

import java.util.List;

public class MainActivity extends AppCompatActivity {
    private static final String TAG = "MainActivity";

    private String fileDir;

    public static final String FILEDIR = Environment
            .getExternalStorageDirectory().getAbsolutePath() + "/downloads";

    private SeekBar mSeekBar;

    private ListView  mListView;
    private DownlistAdapter mDownlistAdapter;
    private List<FileInfo> mFileInfoList;
    private int ParallelTask = 2;  //设置并行任务
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        DownloadTaskManger mDownloadTaskManger = DownloadTaskManger.Holder.getInstance();
        mDownloadTaskManger.init(this,ParallelTask);

        DownloadConfigGuration configGuration1  = new DownloadConfigGuration.Builder()
                .setName("夜神模拟器"+".apk")
                .setUrl("http://sw.bos.baidu.com/sw-search-sp/software/6fbc05830a07e/nox_3.8.0.2_fullPackage.exe")
                .setThreadCount(5)
                .setPriority(1)
                .build();

        DownloadConfigGuration configGuration2  = new DownloadConfigGuration.Builder()
                .setName("网易云"+".apk")
                .setUrl("http://s1.music.126.net/download/android/CloudMusic_2.8.1_official_4.apk")
                .setThreadCount(4)
                .setPriority(1)
                .build();

        DownloadConfigGuration configGuration3  = new DownloadConfigGuration.Builder()
                .setName("腾讯视频"+".apk")
                .setUrl("http://dldir1.qq.com/qqmi/TencentVideo_V4.1.0.8897_51.apk")
                .setThreadCount(4)
                .setPriority(1)
                .build();

        DownloadConfigGuration configGuration4  = new DownloadConfigGuration.Builder()
                .setName("360手机卫士"+".apk")
                .setUrl("http://msoftdl.360.cn/mobilesafe/shouji360/360safesis/360MobileSafe_6.2.3.1060.apk")
                .setThreadCount(4)
                .setPriority(1)
                .build();

        DownloadConfigGuration configGuration5  = new DownloadConfigGuration.Builder()
                .setName("聚美优品"+".apk")
                .setUrl("http://apps.wandoujia.com/apps/com.jm.android.jumei/download")
                .setThreadCount(5)
                .setPriority(1)
                .build();

        mDownloadTaskManger.addTaskConfig(configGuration1);
        mDownloadTaskManger.addTaskConfig(configGuration2);
        mDownloadTaskManger.addTaskConfig(configGuration3);
        mDownloadTaskManger.addTaskConfig(configGuration4);
        mDownloadTaskManger.addTaskConfig(configGuration5);

        mDownloadTaskManger.completedAndStartDownload();

    }


}
